package com.zr.legalfactory.mapper;

import com.zr.legalfactory.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by 陈紫陌 on 2019-10-08.
 */

@Mapper
public interface LegalFactoryMapper {

    List<Corporate> queryLegal(String username);
    int queryCount(PageVo pageVo);
    List<Factory> queryList(@Valid PageVo pageVo);
    @Insert("insert into factory(legalPlantCode,legalPlantDec,enabled," +
            "cid,createName,updateName,createTime,updateTime) values(#{legalPlantCode},#{legalPlantDec}," +
            "#{enabled},#{cid},#{createName},#{updateName},#{createTime},#{updateTime})")
    int add(Factory factory);
    @Select("select * from corporate where legalPersonCode=#{legalPersonCode}")
    Corporate queryCid(@Valid AddVo addVo);
    @Select("select * from factory where legalPlantCode=#{legalPlantCode}")
    Factory queryData(@Valid UpdateVo updateVo);
    @Update("update factory set legalPlantDec=#{legalPlantDec},enabled=#{enabled},updateTime=#{updateTime},updateName=#{updateName} where legalPlantCode=#{legalPlantCode}")
    int update(Factory factory);
    @Update("update factory set enabled=#{enabled} where legalPlantCode=#{legalPlantCode}")
    int updatestatus(OnOffVo onOffVo);
    @Select("select * from corporate where id=#{id}")
    CorporateBo queryBo(Integer id);

    List<CorporateBo> queryList1(List<Integer> ids);

    List<String> queryNames(List<String> plantCodeList);

    int addList(List<Factory> factories);
}
